home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 February: Tool Chest / Dev.CD Feb 99 TC.toast / What's New? / Development Kits / Mac OS USB v1.1f3 DDK / Interfaces / UniversalHIDModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  4.6 KB  |  154 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        UniversalHIDModule.h
  3.  
  4.     Contains:    This describes the interface a higher level part of the OS uses
  5.                 to talk with a UniversalHIDModule, and the way to implement
  6.                 a UniversalHIDModule compliant HID module.
  7.                 
  8.     Version:    xxx put version here xxx
  9.  
  10.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  11.  
  12. */
  13.  
  14. /* We are not USB specific, but we share many definitions with the USB spec*/
  15. #ifndef __UNIVERSALHIDMODULE__
  16. #define __UNIVERSALHIDMODULE__
  17.  
  18. #ifndef __MACTYPES__
  19. #include <MacTypes.h>
  20. #endif
  21. #ifndef __USB__
  22. #include <USB.h>
  23. #endif
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. typedef UInt32                             UHIDModuleConnectionID;
  48. /* FunctionPtr to be called when inturrupt occurs*/
  49. typedef CALLBACK_API_C( void , UHIDInterruptProcPtr )(void *theData, UInt32 refcon);
  50. /* FunctionPtr definitions for UniversalHIDModule dispatch table*/
  51. typedef CALLBACK_API_C( OSStatus , UHIDGetDeviceInfoProcPtr )(UInt32 inInfoSelector, void *outInfo);
  52. typedef CALLBACK_API_C( OSStatus , UHIDGetHIDDescriptorProcPtr )(UInt32 inDescriptorType, UInt32 inDescriptorIndex, UInt32 *ioBufferSize, void *outBuffer);
  53. typedef CALLBACK_API_C( OSStatus , UHIDClaimDeviceProcPtr )(UHIDModuleConnectionID *outConnectionID, UInt32 reserved);
  54. typedef CALLBACK_API_C( OSStatus , UHIDReleaseDeviceProcPtr )(UHIDModuleConnectionID inConnectionID);
  55. typedef CALLBACK_API_C( OSStatus , UHIDInstallInterruptProcPtr )(UHIDModuleConnectionID inConnectionID, UHIDInterruptProcPtr inInterruptProc, UInt32 inRefcon);
  56. typedef CALLBACK_API_C( OSStatus , UHIDControlDeviceProcPtr )(UHIDModuleConnectionID inConnectionID, UInt32 inControlSelector, void *ioControlData);
  57.  
  58. enum {
  59.     kCurrentDispatchTableVersion = 5,
  60.     kOldestCompatableDispatchTableVersion = 5
  61. };
  62.  
  63. /*
  64.    UHIDModuleDispatchTable is exported by the HIDModule's PEF container
  65.    dispatchTableCurrentVersion is kCurrentDispatchTableVersion
  66.    dispatchTableOldestVersion is kOldestCompatableDispatchTableVersion
  67.           (the oldest built client using this API that this UHIDModule will work with)
  68.    vendorID is who wrote this UniversalHIDModule (hi word of 0 and USB vendorID is valid)
  69. */
  70.  
  71. struct UHIDModuleDispatchTableStruct {
  72.     UInt16                             dispatchTableCurrentVersion;
  73.     UInt16                             dispatchTableOldestVersion;
  74.     UInt32                             vendorID;
  75.     UInt32                             vendorSpecific;
  76.     UInt32                             reserved;
  77.     UHIDGetDeviceInfoProcPtr         pUHIDGetDeviceInfo;
  78.     UHIDClaimDeviceProcPtr             pUHIDClaimDevice;
  79.     UHIDReleaseDeviceProcPtr         pUHIDReleaseDevice;
  80.     UHIDInstallInterruptProcPtr     pUHIDInstallInterrupt;
  81.     UHIDControlDeviceProcPtr         pUHIDControlDevice;
  82.     UHIDGetHIDDescriptorProcPtr     pUHIDGetHIDDescriptor;
  83. };
  84. typedef struct UHIDModuleDispatchTableStruct UHIDModuleDispatchTableStruct;
  85.  
  86. typedef UHIDModuleDispatchTableStruct     UHIDModuleDispatchTable;
  87. typedef UHIDModuleDispatchTableStruct *    UHIDModuleDispatchTablePtr;
  88. /* the prototypes for the actual functions in the UHIDModule follow*/
  89. EXTERN_API_C( OSStatus )
  90. UHIDGetDeviceInfo                (UInt32                 inInfoSelector,
  91.                                  void *                    outInfo);
  92.  
  93. EXTERN_API_C( OSStatus )
  94. UHIDGetHIDDescriptor            (UInt32                 inDescriptorType,
  95.                                  UInt32                 inDescriptorIndex,
  96.                                  UInt32 *                ioBufferSize,
  97.                                  void *                    outBuffer);
  98.  
  99. /* Claim and release are a way to insure that only one client is connected*/
  100. EXTERN_API_C( OSStatus )
  101. UHIDClaimDevice                    (UHIDModuleConnectionID * outConnectionID,
  102.                                  UInt32                 reserved);
  103.  
  104. EXTERN_API_C( OSStatus )
  105. UHIDReleaseDevice                (UHIDModuleConnectionID  inConnectionID);
  106.  
  107. EXTERN_API_C( OSStatus )
  108. UHIDInstallInterrupt            (UHIDModuleConnectionID  inConnectionID,
  109.                                  UHIDInterruptProcPtr     inInterruptProc,
  110.                                  UInt32                 inRefcon);
  111.  
  112. EXTERN_API_C( OSStatus )
  113. UHIDControlDevice                (UHIDModuleConnectionID  inConnectionID,
  114.                                  UInt32                 inControlSelector,
  115.                                  void *                    ioControlData);
  116.  
  117. /* these are the constants to be passed to UHIDControlDevice*/
  118.  
  119. enum {
  120.     kUHIDRemoveInterruptHandle    = 0,
  121.     kUHIDVendorSpecificControlStart = 0x00010000
  122. };
  123.  
  124. /* these are the constants to be passed to UHIDGetDeviceInfo*/
  125.  
  126. enum {
  127.     kUHIDGetVendorID            = 0,
  128.     kUHIDGetProductID            = 1,
  129.     kUHIDGetMaxPacketSize        = 2,
  130.     kUHIDVendorSpecificGetInfoStart = 0x00010000
  131. };
  132.  
  133.  
  134. #if PRAGMA_STRUCT_ALIGN
  135.     #pragma options align=reset
  136. #elif PRAGMA_STRUCT_PACKPUSH
  137.     #pragma pack(pop)
  138. #elif PRAGMA_STRUCT_PACK
  139.     #pragma pack()
  140. #endif
  141.  
  142. #ifdef PRAGMA_IMPORT_OFF
  143. #pragma import off
  144. #elif PRAGMA_IMPORT
  145. #pragma import reset
  146. #endif
  147.  
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151.  
  152. #endif /* __UNIVERSALHIDMODULE__ */
  153.  
  154.